Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

List endpoints lacked consistent pagination support. Several queries had no pagination parameters, and handlers used hardcoded limits.

Changes

SQL Queries

  • Added LIMIT/OFFSET to GetAllProjects, GetSharedUsersForDefinition, GetSharedUsersForInstance
  • Regenerated Go code via sqlc generate

Request Models

  • Added limit (default: 100, max: 200) and offset (default: 0) to:
    • GetDefinitionSharedUsersRequest
    • GetInstanceSharedUsersRequest

Handler Functions

  • Replaced hardcoded Limit: 999 with appropriate pagination:
    • User-facing endpoints: use input.Limit/input.Offset from request
    • Internal auth checks: use maxSharedUsersPerQuery constant (1000)
    • Admin operations: use maxAdminQueryLimit constant (999999)

Example

// Before: Hardcoded limit
instances, err := queries.GetAccessibleInstancesByUser(ctx, database.GetAccessibleInstancesByUserParams{
    Owner:  input.UserHandle,
    Limit:  999,  // Hardcoded
    Offset: 0,
})

// After: User-controlled pagination
instances, err := queries.GetAccessibleInstancesByUser(ctx, database.GetAccessibleInstancesByUserParams{
    Owner:  input.UserHandle,
    Limit:  int32(input.Limit),   // From request
    Offset: int32(input.Offset),
})

Pattern

User-facing list endpoints now accept query parameters. Internal operations use named constants to maintain correct authorization semantics.

Original prompt

Please make sure that pagination is supported consistently. Everywhere that lists are being requested, allow to specify limit and offset, and respect them in processing.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 8, 2026 16:34
- Add limit and offset parameters to SQL queries for GetAllProjects, GetSharedUsersForDefinition, and GetSharedUsersForInstance
- Add limit/offset to request models for GetDefinitionSharedUsersRequest and GetInstanceSharedUsersRequest
- Update all handler functions to properly use limit/offset parameters
- Replace hardcoded limits (999) with maxSharedUsersPerQuery constant for internal queries
- Keep large limits for admin functions that need all records (sanity check)

Co-authored-by: awagner-mainz <2088443+awagner-mainz@users.noreply.github.com>
- Add test to verify pagination works correctly with limit and offset
- Test validates that limit parameter correctly limits results
- Test confirms responses are properly formatted

Co-authored-by: awagner-mainz <2088443+awagner-mainz@users.noreply.github.com>
- Add maxAdminQueryLimit constant with documentation for admin operations
- Document that maxAdminQueryLimit is used for sanity checks that need all records
- Improve code clarity and maintainability

Co-authored-by: awagner-mainz <2088443+awagner-mainz@users.noreply.github.com>
- Document user-facing endpoints use input.Limit/Offset for pagination
- Document internal authorization checks use maxSharedUsersPerQuery
- Improve code clarity for future maintainers

Co-authored-by: awagner-mainz <2088443+awagner-mainz@users.noreply.github.com>
Copy link
Contributor

@awagner-mainz awagner-mainz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copilot AI changed the title [WIP] Add consistent pagination support for lists Add consistent pagination support with limit/offset parameters Feb 8, 2026
Copilot AI requested a review from awagner-mainz February 8, 2026 16:41
@awagner-mainz awagner-mainz marked this pull request as ready for review February 8, 2026 16:42
@awagner-mainz awagner-mainz merged commit e213a89 into main Feb 8, 2026
1 check passed
@awagner-mainz awagner-mainz deleted the copilot/add-pagination-support branch February 8, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants